package com.abo.yaas.webservice.client;

import com.abo.yaas.domain.Bid;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.vaadin.addon.jpacontainer.Filter;
import com.vaadin.addon.jpacontainer.filter.ComparisonFilter;

@SuppressWarnings("serial")
public class BidProviderProxy extends EntityProviderProxy<Bid> {
    public BidProviderProxy(WebResource resource) {
        super(Bid.class, resource);
    }

    @Override
    protected void prepareFilter(MultivaluedMapImpl params, Filter filter) {
        if (filter == null) {
            return;
        }
        String property = "";
        Object value = null;

        if (filter instanceof ComparisonFilter) {
            final ComparisonFilter compFilter = (ComparisonFilter) filter;
            property = compFilter.getPropertyId().toString();
            value = compFilter.getValue();
            if ("auctionId".equals(property)) {
                params.putSingle("auctionId", value);
            }
        }
    }
}
